from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service
from selenium.webdriver.chrome.service import Service


def wait_element_not_exist(driver, locator, timeout=45, poll_frequency: float = 0.5):
    res = WebDriverWait(driver, timeout, poll_frequency=poll_frequency).until_not(EC.visibility_of_element_located(locator))
    return res


driver_path = './chromdriver_path/chromedriver.exe'
driver = webdriver.Chrome(executable_path=driver_path)

driver.get('http://www.baidu.com')
# res = wait_element_not_exist(driver=driver, locator=(By.ID, 'su'))
# print(res)
